<script>
import { mapActions } from "vuex";
import { languageManager } from "@/utils/language.js";

export default {
  methods: {
    ...mapActions("user", ["loadLanguagePack"]),
    async initializeLanguage() {
      try {
        console.log("开始初始化语言管理器...");

        // 首先初始化当前语言
        const currentLanguage = languageManager.getCurrentLanguage();
        console.log("当前语言设置为:", currentLanguage);

        // 然后加载远程语言包（可选）
        // console.log('开始加载语言包...')
        // await this.loadLanguagePack()
        // console.log('语言包加载完成')
      } catch (error) {
        console.error("语言包初始化失败:", error);
      }
    },
  },
  onLaunch: function () {
    console.log("App Launch");
    uni.getSystemInfo({
      success: (res) => {
        if (res.language === "zh-CN") {
          this.globalData.systemLanguage = "en-US";
        } else {
          this.globalData.systemLanguage = res.language;
        }
      },
    });

    // 初始化语言包
    this.initializeLanguage();
  },
  onShow: function () {
    console.log("App Show");
  },
  onHide: function () {
    console.log("App Hide");
  },
  globalData: {
    systemLanguage: "",
  },
};
</script>

<style lang="scss">
/*每个页面公共css */
@import "./style/global.scss";

.page {
  position: relative;
  margin: 0 auto;
}

@media (min-width: 800px) {
  .page {
    position: relative;
    width: 375px !important;
  }
}

.model-content {
  width: 512rpx;
  padding: 14rpx 30rpx;
  box-sizing: border-box;
  position: relative;

  .contents {
    width: 100%;
  }

  .close-img {
    position: absolute !important;
    width: 37px;
    height: 37px;
    right: -7px;
    top: 12px;
  }
}

.inp-wrap {
  width: 100%;
  height: 38px;
  background: #5c8a50;
  box-shadow: 0 1px 2px 0 #43573f;
  border-radius: 6px;
  padding: 0 12px;
  box-sizing: border-box;
}

.gg-tips {
  height: 43px;
  margin: 0 auto;
  padding: 6px;
  box-sizing: border-box;
  background: url(/static/img/tips.png) no-repeat;
  background-size: 100%;
  color: #683436;
  font-size: 14px;
  font-weight: 700;
}
</style>
